import { useImperativeHandle, forwardRef, useRef } from 'react';
import Form from 'com/Form';
import Modal from 'com/Modal';

export default forwardRef((props, ref) => {
    const { title, options, onFinish, formAttrs, modalAttrs, values, lw } = props;
    const form = useRef();
    const modal = useRef();

    useImperativeHandle(ref, () => ({
        ...modal.current
    }));

    return <Modal ref={modal} attrs={modalAttrs} title={title} onOk={() => form.current.submit()}>
        <Form onFinish={onFinish} lw={lw} ref={form} options={options} values={values} attrs={formAttrs} />
    </Modal>
});